package com.mr.cai.main.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mr.cai.main.R;

/**
 * Created by Administrator on 2015/7/10.
 */
public class MrCaiLoadingLayout extends FrameLayout {

    private Context mContext;
    private RelativeLayout rlCommonLoading;

    private TextView tvContent;
    private ProgressBar pbLoading;

    public MrCaiLoadingLayout (Context context) {
        super(context);
        mContext = context;
        initView();
    }

    public MrCaiLoadingLayout (Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
        initView();
    }

    public MrCaiLoadingLayout (Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext = context;
        initView();
    }

    private void initView () {
        setViewGone();
        LayoutInflater.from(mContext).inflate(R.layout.layout_mr_cai_loading, this);
        rlCommonLoading = (RelativeLayout) this.findViewById(R.id.rl_common_loading);
        FrameLayout.LayoutParams params = (LayoutParams) rlCommonLoading.getLayoutParams();
        params.gravity = Gravity.CENTER;
        rlCommonLoading.setLayoutParams(params);

        tvContent = (TextView) findViewById(R.id.tv_loading_content);
        pbLoading = (ProgressBar) findViewById(R.id.pb_loaing);

    }

    public void setViewType () {
        this.setVisibility(View.VISIBLE);
        pbLoading.setVisibility(View.VISIBLE);
        tvContent.setVisibility(View.GONE);
    }


    public void setViewGone () {
        this.setVisibility(View.GONE);
    }

    @Override
    public boolean onTouchEvent (MotionEvent event) {
        return true;
    }
}
